<template>
  <!--  轮播图页面-->
  <div class="home-carousel">
    <el-carousel :autoplay="true" arrow="always" height="896px" indicator-position="none">
      <el-carousel-item v-for="(item,index) in rotationList" :key="index">
        <router-link :to="{name:'rotationDetail', query: {id:item.id}}" target="_blank">
          <div class="content">
            <zooming-image :image-src="item.cover" :duration="4"
                           :scale="1.1"
            ></zooming-image>
            <span>{{ item.title }}</span>
          </div>
        </router-link>
      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<script>
import { listRotation } from '@/api/rotation/rotation'
import { cutString } from '../../../utils/ruoyi'
import ImageNonePreview from '@/components/ImagePreview/ImageNonePreview.vue'
import ZoomingImage from '@/components/ImagePreview/ZoomingImage.vue'

export default {
  name: 'CarouselItem',
  components: { ZoomingImage, ImageNonePreview },

  data() {
    return {
      // 遮罩层
      loading: true,

      // 轮播图表格数据
      rotationList: [],
      queryParams: {
        online: 1
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    cutString,
    /** 查询轮播图列表 */
    getList() {
      this.loading = true
      listRotation(this.queryParams).then(response => {
        this.rotationList = response.rows
        this.total = response.total
        this.loading = false
      })
    }

  }
}
</script>

<style lang="scss" scoped>
.home-carousel {
  width: 100%;
}

::v-deep .el-carousel__button {
  height: 6px;
  width: 50px;
}

::v-deep .el-carousel__arrow {
  height: 80px;
  width: 80px;
  border-radius: 50%;
  color: #FFF;
  text-align: center;
  font-size: 50px;
}

::v-deep .el-carousel__arrow--left {
  left: 0;
}

::v-deep .el-carousel__arrow--right {
  right: 0;
}

.content {
  position: relative;
  width: 100%;



  span {
    display: block;
    height: 63px;
    width: 100%;
    text-align: center;
    position: absolute;
    display: inline-block;
    padding-left: 20px;
    line-height: 63px;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 2;
    bottom: 0px;
    color: #fff;
    left: 0px;
    font-size: 22px;
    letter-spacing: 1.5px;
    font-family: sans-serif;
  }
}
</style>
